package com.uppfind.framework.core.validator.constraintvalidators;

import com.uppfind.framework.core.validator.constraints.NotMessyCode;
import com.uppfind.framework.utils.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class MessyCodeValidator implements ConstraintValidator<NotMessyCode, String> {

    @Override
    public void initialize(NotMessyCode notMessyCode) {
    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if (null == s) return true;
        return !StringUtils.isMessyCode(s);
    }

}
